package com.factory.server.bo;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.Parameter;

/**
 * AbstractBusinessObject is superobject for all entity beans.
 *
 * @author Pavel Micka (mickapa1@fel.cvut.cz)
 */
@SuppressWarnings("serial")
@MappedSuperclass
public abstract class AbstractBusinessObject implements Serializable {

    @GenericGenerator(name = "table-hilo-generator", strategy = "org.hibernate.id.TableHiLoGenerator",
    parameters = {
        @Parameter(value = "hibernate_id_generation", name = "table")})
    @GeneratedValue(generator = "table-hilo-generator")
    @Id
    protected Long id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        } else if (!(obj instanceof AbstractBusinessObject)) {
            return false;
        }
        return ((AbstractBusinessObject) obj).getId()==(this.getId());
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = (int) (97 * hash + (this.id));
        return hash;
    }
}
